package main

import (
	"bytes"
	"encoding/gob"
	"fmt"
)

var in = make(chan map[string]interface{})
var out = make(chan map[string]interface{})

type Tmp struct {
	Name   string
	Age    int
	Object *Object
}
type Object struct {
	Book string
}

func deepCopy(dst, src interface{}) error {
	var buf bytes.Buffer
	if err := gob.NewEncoder(&buf).Encode(src); err != nil {
		return err
	}
	return gob.NewDecoder(bytes.NewBuffer(buf.Bytes())).Decode(dst)
}

var a = []*Tmp{{
	Name:   "aa",
	Age:    1,
	Object: &Object{Book: "abook"},
}}

type TestDeepCopyObject struct {
	Age  int
	Name string
	D    *string
}

func testDeepCopy() {
	var i = 2
	var name = "33"
	a := TestDeepCopyObject{
		Age:  i,
		Name: name,
		D:    &name,
	}
	b := TestDeepCopyObject{}
	err := deepCopy(&b, &a)
	fmt.Println(err)
	fmt.Printf("%p\n", a.D)
	fmt.Printf("%p\n", b.D)
}

func main() {

}
func updateFlags(out chan map[string]interface{}, in chan map[string]interface{}) {
	flags := <-out
	flags["sdf"] = "sdf"
	in <- flags
}
